import {RulePanel} from "../RulePanel";
import { assert, expect } from "chai";

$(() => {
    console.log("rule test")
});

suite('rule',()=>{
    setup(function() {
        // ...
    });

    suite('panel', function() {
        test('show', function() {
            assert.equal(-1, [1,2,3].indexOf(4));
            let d = new RuleTest();
            d.init()
            let len = $('#db_column').find("select").length
            console.log(len)
            assert(len > 0)
            console.log($('#mocha').html())
        });
    });
})

class RuleTest{
    private ruleUse =[]
    private ruleCand = []

    public init() {
        //使用这种方法保证函数上下文的this可用
        let onChoose = (rule: RulePanel) => {
            if (rule.isUse) {
                $("#r_select").append($(`#${rule.id}`))
                this.ruleUse.push(rule)
            }
            else {
                $("#r_cand").append($(`#${rule.id}`))
                this.ruleCand.push(rule)
            }
        }
        this.ruleCand.push({'dbcc': new RulePanel("db_column", onChoose, true)})
        this.ruleCand.push({'ddd': new RulePanel("db_column1", onChoose)})
    }
}